﻿using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Service.Model.Map
{
    public class PlayerMap : EntityTypeConfiguration<Player>
    {
        public PlayerMap()
        {
            ToTable("dbo.Players");
            HasKey(p => p.PlayerId);

            Property(p => p.PlayerId).HasColumnName("PlayerId").IsRequired().HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            Property(p => p.Difficulty).HasColumnName("Difficulty").IsOptional();

            HasMany(p => p.PlayerHeuristics).WithRequired(ph => ph.Player).HasForeignKey(ph => ph.PlayerId);
            HasMany(p => p.GamePlayers).WithRequired(gp => gp.Player).HasForeignKey(gp => gp.PlayerId);
        }
    }
}